/***************************************************************************
 *   Copyright (C) 2009 by Jason Pullara                                   *
 *   lordkat@gmail.com                                                     *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/

using namespace std;

class cClient;
class cCharacter;
class cNetwork;

/* For common structures */

struct sQuestData {
	unsigned long ulQuestID;	/* Quest number */
	unsigned char ucPart; 		/* Quest section you're currently in */
};

struct sInventoryData {
	unsigned long ulItemID;	/* Item ID */
	unsigned char ucNum;	/* Number in Inventory */
};

struct sStatusData {
	unsigned long ulStatusID;	/* Status ID */
	time_t tStart;				/* Time status was induced */
	time_t tDuration;			/* How long status will last */
	time_t tRepeat;				/* How often effects repeat themselves (eg, poison) */
};

struct sItemData {
	string sName;
	string sDesc;
};

struct sMapData {
	string sZone;
	string sDesc;
};

/* We've limited the number of jobs to MAX_JOBS. There's more memory overhead when
doing this, but there's a performance increase to being able to directly address
the array, rather than search through it with a list or vecotor. Since I don't think
this game is going to get a whole lot of people on at once, this should suffice.

Everything from ulHP down to ucMEv is calculated with levelChange(), so we're not
going to store them in the save file, rather just levelChange() on login.

CPU expensive? Sure, but it beats trying to maintain that fucking FileIO shit. */
struct sCharacterData {
	string sName;
	string sPassword;
	string sTitle;						/* Title given by quests or defeating epic monsters */
	unsigned char ucJob;				/* Stores the current Job */
	unsigned char ucSubJob;				/* Stores the current Sub Job (if any) */
	unsigned char ucRace;				/* Race */

	string sJobLong;
	string sJobShort;
	string sJobRank;
	string sSubLong;
	string sSubShort;
	string sSubRank;
	string sRaceLong;
	string sRaceShort;
	string sRaceRank;

	unsigned int uiLevel[MAX_JOBS];		/* Array of levels for every job */
	unsigned long ulExp[MAX_JOBS];		/* Array of experience points for every job */
	unsigned long ulGold;				/* Gold is universal across your jobs */
	unsigned long ulMap;				/* Map number the character is on */

	unsigned long ulHP;	/* Current HP */
	unsigned long ulMP;	/* Current MP */
	unsigned long ulTP;	/* Current TP */

	unsigned long ulEqHead;
	unsigned long ulEqNeck1;
	unsigned long ulEqNeck2;
	unsigned long ulEqEar1;
	unsigned long ulEqEar2;
	unsigned long ulEqBack;
	unsigned long ulEqChest;
	unsigned long ulEqArms;
	unsigned long ulEqHands;
	unsigned long ulEqWaist1;
	unsigned long ulEqWaist2;
	unsigned long ulEqLegs;
	unsigned long ulEqFeet;
	unsigned long ulEqHold1; // Held items: Weapons, shields, etc...
	unsigned long ulEqHold2; // Held items: Weapons, shields, etc...
	unsigned long ulEqRangedWeapon;
	unsigned long ulEqRangedAmmo;

	list<sInventoryData> lInventory;
	list<sQuestData> lQuests;

	list<sStatusData> lStatusEffects;
	list<unsigned long> lFlags;

	/*************************************
	** BELOW HERE IS NOT SAVED TO DISK  **
	**                                  **
	** Instead we calculate it on login **
	*************************************/

	/* These stats use unsigned long because
	epic monsters will exceed unsigned int values.

	We don't need to store an array for Current HP SP and TP
	because it changes to its maximum value on job change. */
	unsigned long ulMaxHP;	/* Maximum HP */
	unsigned long ulMaxMP;	/* Maximum SP */
	unsigned long ulMaxTP;	/* Maximum TP */

	unsigned long ulTNL;	/* XP needed to level */

	unsigned int uiStr;		/* Strength */
	unsigned int uiDex;		/* Dexterity */
	unsigned int uiVit;		/* Vitality */
	unsigned int uiAgi;		/* Agility */
	unsigned int uiInt;		/* Intelligence */
	unsigned int uiMnd;		/* Mind */
	unsigned int uiChr;		/* Charisma */
	unsigned int uiAtk;		/* Attack Power */
	unsigned int uiDef;		/* Defense */
	unsigned int uiAcc;		/* Accuracy */
	unsigned int uiEva;		/* Evasion */
	unsigned int uiMAc;		/* Magical Accuracy */
	unsigned int uiMEv;		/* Magical Evasion */

	unsigned int uiStrMod;
	unsigned int uiDexMod;
	unsigned int uiVitMod;
	unsigned int uiAgiMod;
	unsigned int uiIntMod;
	unsigned int uiMndMod;
	unsigned int uiChrMod;
	unsigned int uiAtkMod;
	unsigned int uiDefMod;
	unsigned int uiAccMod;
	unsigned int uiEvaMod;
	unsigned int uiMAcMod;
	unsigned int uiMEvMod;

	unsigned int uiDamage;
	unsigned int uiDelay;
};

struct sStatusTable {
	unsigned char cID;
	const char *cShortName;
	const char *cLongName;
	char cHP;
	char cMP;
	char cStr;
	char cDex;
	char cVit;
	char cAgi;
	char cInt;
	char cMnd;
	char cChr;
};

struct sScaleTable {
	unsigned char cID;
	float fHPBase;
	float fHPScale;
	float fHPScaleMod;
	float fMPBase;
	float fMPScale;
	float fMPScaleMod;
	float fStatsBase;
	float fStatsScale;
	float fStatsScaleMod;
};

struct sCommandTable {
	const char *cCommand;
	void (*vCommand)(string, cClient*, cNetwork*);
	CharacterRace limitRace;
	CharacterJob limitJob;
	CharacterFlags limitFlags;
};

struct sExperienceTable {
	unsigned int uiLevel;
	unsigned int uiScale;
};

struct sHitData {
	HitType hitType;
	unsigned long ulDamage;
};
